FREAD
Section: MINTLIB LIBRARY FUNCTIONS
(3)
Updated: 3 March 1993
Index
Return to Main Contents
NAME
fread, fwrite - buffered binary input/output
SYNOPSIS
#include <stdio.h>
size_t fread (void *ptr, size_t size, size_t nitems,
FILE *stream);
size_t fwrite (const void *ptr, size_t size, size_t nitems,
FILE *stream);
DESCRIPTION
fread reads, into a block pointed to by ptr, nitems items
of data from the named input stream stream, where an item of
data is a sequence of bytes (not necessarily terminated by a
null byte) of length size. It returns the number of items
actually read. fread stops reading if an end-of-file or
error condition is encountered while reading from stream, or
if nitems items have been read. fread leaves the file
pointer in stream, if defined, pointing to the byte follow-
ing the last byte read if there is one. fread does not
change the contents of the file referred to by stream.
fwrite writes at most nitems items of data from the block
pointed to by ptr to the named output stream stream. It
returns the number of items actually written. fwrite
stops writing when it has written nitems items of data or if
an error condition is encountered on stream. fwrite does
not change the contents of the block pointed to by ptr.
If size or nitems is non-positive, no characters are read or
written and 0 is returned by both fread and fwrite.
RETURN VALUES
fread and fwrite return the number of elements read on
success, 0 on failure.
SEE ALSO
read(3),
write(3),
fopen(3),
getc(3),
gets(3),
putc(3),
puts(3),
printf(3),
scanf(3)
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- RETURN VALUES
-
- SEE ALSO
-
This document was created by
man2html,
using the manual pages.
Time: 11:14:51 GMT, June 22, 2025